//
//  YWPostTroubleInfoCell.m
//  maintain
//
//  Created by Kyo on 16/8/4.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWPostTroubleInfoCell.h"
#import "YWMission.h"
#import "YWHandler.h"
#import "UIView+Extension.h"
#import "YWMacro.h"
#import "YWEquipmentManager.h"
#import "YWTroubleMissionModel.h"
#import "YWReportTroubleModel.h"
#import "YWEquipment.h"

@implementation YWPostTroubleInfoCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"YWPostTroubleInfoCellIdentifier";
    YWPostTroubleInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[YWPostTroubleInfoCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.font = kContentFont;
        cell.detailTextLabel.font = KSmallContentFont;
        cell.detailTextLabel.textColor = [UIColor lightGrayColor];
    }
    return cell;
}

//- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
//    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
//    if (self) {
//    }
//    return self;
//}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.textLabel.x = kMarginW;
    self.detailTextLabel.x = kMarginW;
}

- (void)setReportTrouble:(YWReportTroubleModel *)reportTrouble{
    _reportTrouble = reportTrouble;
    if (reportTrouble) {
        if (reportTrouble.equipment.equipmentId && reportTrouble.equipment.equipmentName.length) {
            self.textLabel.text = reportTrouble.equipment.equipmentName;
        }else{
            self.textLabel.text = NSLocalizedString(@"locationPostTrouble", nil);//@"位置报障";//无
        }
        
        self.detailTextLabel.text = reportTrouble.note.length>0?[NSString stringWithFormat:@"%@: %@",NSLocalizedString(@"note", nil),reportTrouble.note]:[NSString stringWithFormat:@"%@: %@",NSLocalizedString(@"note", nil),NSLocalizedString(@"none", nil)];
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else{
        self.textLabel.text = NSLocalizedString(@"noPostTrouble", nil);
        self.detailTextLabel.text = nil;
        self.accessoryType = UITableViewCellAccessoryNone;
    }
}
@end
